package com.shenzhen.horselive.adapter;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter;

import java.util.List;

public class MyViewPageAdapter extends FragmentPagerAdapter {
   List<Fragment>  list;
   List<String>   strings;

    public MyViewPageAdapter(@NonNull FragmentManager fm,List<Fragment> list) {
        super(fm);
        this.list = list;
    }


    public MyViewPageAdapter(@NonNull FragmentManager fm,List<Fragment> list,List<String>   strings) {
        super(fm);
        this.list = list;
        this.strings =strings;
    }

    @NonNull
    @Override
    public Fragment getItem(int position) {
        return list.get(position);
    }

    @Override
    public int getCount() {
        if (list==null)
        return 0;
        else return list.size();
    }

    @Nullable
    @Override
    public CharSequence getPageTitle(int position) {
        if (strings!=null)
        return strings.get(position);
        else
            return super.getPageTitle(position);
    }
}
